package us.mooresr.aircraftscheduling.client.gin;

import com.gwtplatform.dispatch.shared.SecurityCookie;
import com.gwtplatform.mvp.client.gin.AbstractPresenterModule;
import com.gwtplatform.mvp.client.gin.DefaultModule;

import us.mooresr.aircraftscheduling.client.place.ClientPlaceManager;
import us.mooresr.aircraftscheduling.client.place.DefaultPlace;
import us.mooresr.aircraftscheduling.client.place.ReservationList;
import us.mooresr.aircraftscheduling.client.place.NameTokens;
import us.mooresr.aircraftscheduling.client.place.UserList;
import us.mooresr.aircraftscheduling.client.ui.LoginPresenter;
import us.mooresr.aircraftscheduling.client.ui.LoginView;
import us.mooresr.aircraftscheduling.client.ui.ReservationListPresenter;
import us.mooresr.aircraftscheduling.client.ui.ReservationListView;
import us.mooresr.aircraftscheduling.client.ui.ReservationDetailPresenter;
import us.mooresr.aircraftscheduling.client.ui.ReservationDetailView;
import us.mooresr.aircraftscheduling.client.ui.UserListPresenter;
import us.mooresr.aircraftscheduling.client.ui.UserListView;
import us.mooresr.aircraftscheduling.client.ui.UserDetailPresenter;
import us.mooresr.aircraftscheduling.client.ui.UserDetailView;
import us.mooresr.aircraftscheduling.client.ui.MainPagePresenter;
import us.mooresr.aircraftscheduling.client.ui.MainPageView;
import us.mooresr.aircraftscheduling.client.ui.UserDetailROPresenter;
import us.mooresr.aircraftscheduling.client.ui.UserDetailROView;

public class ClientModule extends AbstractPresenterModule {

	@Override
	protected void configure() {
		
		// Singletons
		install(new DefaultModule(ClientPlaceManager.class));

		// Constants
		bindConstant().annotatedWith(DefaultPlace.class).to(NameTokens.login);
		bindConstant().annotatedWith(SecurityCookie.class).to("JSESSIONID");
		bindConstant().annotatedWith(ReservationList.class).to(NameTokens.reservationlist);
		bindConstant().annotatedWith(UserList.class).to(NameTokens.userlist);
		
		// Presenters
		bindPresenter(LoginPresenter.class, LoginPresenter.MyView.class,
				LoginView.class, LoginPresenter.MyProxy.class);
		
		bindPresenter(ReservationListPresenter.class, ReservationListPresenter.MyView.class,
				ReservationListView.class, ReservationListPresenter.MyProxy.class);

		bindPresenterWidget(ReservationDetailPresenter.class,
				ReservationDetailPresenter.MyView.class,
				ReservationDetailView.class);

		bindPresenter(UserListPresenter.class, UserListPresenter.MyView.class,
				UserListView.class, UserListPresenter.MyProxy.class);
		
		bindPresenterWidget(UserDetailPresenter.class,
				UserDetailPresenter.MyView.class, UserDetailView.class);

		bindPresenter(MainPagePresenter.class, MainPagePresenter.MyView.class,
				MainPageView.class, MainPagePresenter.MyProxy.class);

		bindPresenterWidget(UserDetailROPresenter.class,
				UserDetailROPresenter.MyView.class, UserDetailROView.class);
	}
}
